/** 
 * 项目名:shiro 
 * 文件名:MyRealm3.java 
 * 包名:com.spring.shiro.realm 
 * 创建日期:2015年2月13日下午2:41:32 
 * 版权(c): ZTESOFT TECHNOLOGY CO.,LTD.Copyright 2012-2030.All rights reserved
 * 
*/  
  
package com.spring.shiro.realm;  

import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.authc.AuthenticationInfo;
import org.apache.shiro.authc.AuthenticationToken;
import org.apache.shiro.authc.SimpleAuthenticationInfo;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.realm.Realm;

import com.spring.shiro.po.User;
 
public class MyUserRealm3 implements Realm {

	@Override
	public String getName() {

		return "c";
	}

	@Override
	public boolean supports(AuthenticationToken token) {

		return token instanceof UsernamePasswordToken;
	}

	@Override
	public AuthenticationInfo getAuthenticationInfo(AuthenticationToken token) throws AuthenticationException {

		User user = new User("zhang", "123");  
        return new SimpleAuthenticationInfo(  
            user, //身份 User类型  
            "123",   //凭据  
            getName() //Realm Name  
        );  
	}

}
  